package br.ufrn.cep.eEtica.negocio.rest;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import br.ufrn.cep.eEtica.integracao.dao.GenericDAO;

public abstract class GenericRS<T> {
	
	GenericDAO dao;
	
	public GenericDAO getDao(){
		dao = GenericDAO.getInstance();
		return dao;
	}
	
	/**
	 * /<nomeDaEntidade>/listar
	 * @return List<T>
	 */
	@GET 
	@Path("/listar/")
	@Produces(MediaType.TEXT_XML)
	public abstract List<T> list();
	
	/**
	 * /<nomeDaEntidade>
	 * 
	 * @param id
	 * @return <T>
	 */
	@GET
	@Produces(MediaType.TEXT_XML)
	public abstract T getById(@QueryParam("id")int id);
	
	/**
	 * /<nomeDaEntidade>/cadastrar
	 * 
	 * @param element
	 * @return <T>
	 */
	@POST
	@Path("/cadastrar/")
	@Produces(MediaType.TEXT_XML)
	@Consumes(MediaType.TEXT_XML)
	public abstract T create(T element);
	
	/**
	 * /<nomeDaEntidade>/atualizar
	 * 
	 * @param element
	 * @return <T>
	 */
	@PUT
	@Path("/atualizar/")
	@Produces(MediaType.TEXT_XML)
	@Consumes(MediaType.TEXT_XML)
	public abstract T update(T element);

	/**
	 * /<nomeDaEntidade>/remover
	 * @param id
	 */
	@DELETE
	@Path("/remover/")
	public abstract void delete(@QueryParam("id")int id);
	
}
